package com.myway.dto.order;

import com.myway.dto.insurance.DTOInsurance;
import com.myway.dto.order.domain.SegmentStatus;
import com.myway.dto.order.domain.TicketStatus;
import com.myway.dto.product.DTOSupportBusinessOrder;
import com.myway.dto.seat.DTOEtAsrSeat;
import com.myway.dto.ticket.DTOTicket;
import org.apache.commons.beanutils.BeanUtils;

import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

//import com.hna.mars.service.product.dto.DTOProduct;

/**
 * @类名称：DTOPaxSegment 
 * @类描述：旅客航段 
 * @创建时间：2015年11月11日 下午7:51:19 
 * @author Jiang.Yida
 * @version V1.0
 */
public class DTOPaxSegment extends DTOSegment {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5895199028264423976L;

	private Long passengerId;
	private Long segmentId;
	private DTOPassenger pass;
	private DTOTicket ticketIssued;
//	private DTOProduct productApplied;
	private double marketFare;
	private double netFare;
	private double airportTax;
	private double fuelTax;
	private double otherTaxes;
	private double insurance;
	private double agentFeeRate;
	private double spFeeRate;
	private double agentFee;
	private double spFee;
	private String fareBasis;
	private Date notValidBefore;
	private Date notValidAfter;
	private String allow;
	private SegmentStatus status;
	private TicketStatus ticketStatus;
	private String currency;
	/**
	 * 有免票资格？
	 */
	private String hasFreeTicket ;
	/**
	 * 免票资格已使用

	 */
	private String usedFreeTicket ;
	/**
	 * 是否已成行

	 */
	private String usrdFlow ;
	/**
	 * 使用免票支付
	 */
	private String payFreeTicket;
	
	/**
	 * 航段序号
	 */
	private int sequence;
	
	/**
	 * for 行程单展现

	 */
	private String dayAndMoth;
	private String hourAndmin;

	private List<DTOEtAsrSeat> seatList=new ArrayList<DTOEtAsrSeat>();

	private List<DTOPaxSegmentService> serviceList = new ArrayList<DTOPaxSegmentService>();
	private List<DTOInsurance> insuranceList = new ArrayList<DTOInsurance>();
	private List<DTOPaxsegTax> paxsegTaxList = new ArrayList<DTOPaxsegTax>();
	
	private List<DTOSupportBusinessOrder> supportBusinessList = new ArrayList<DTOSupportBusinessOrder>();
	
	private DTOOrderExtbuy extBuy;//补购订单

	//优惠卷价格
	private BigDecimal couponPrice;
	//原应付价
	private BigDecimal oldNetFare;
	//订单id
	private Long orderId;
	//规则ID
	private Long ruleId;
	
	/**
	 * 积分(金币支付总额)
	 */
	private double pointPrice=0;

    /**
     * 真实折扣：特价产品/基础运价 用于计算退票费率
     */
    private double realRebate = 0;
	
	public DTOPaxSegment() {}
	
	
	/**
	 * @return the paxsegTaxList
	 */
	public List<DTOPaxsegTax> getPaxsegTaxList()
	{
		return paxsegTaxList;
	}

	
	/**
	 * @param paxsegTaxList the paxsegTaxList to set
	 */
	public void setPaxsegTaxList(List<DTOPaxsegTax> paxsegTaxList)
	{
		this.paxsegTaxList = paxsegTaxList;
	}

	/**
	 * Instantiate passenger segment based on the specified segment.
	 * 
	 * @param segment
	 *            Contains basic segment details of which this passenger segment will be based on.
	 */
	public DTOPaxSegment(DTOSegment segment) {
		this(null, segment);
	}
	
	/**
	 * Instantiate passenger segment based on the passenger ID and segment.
	 * 
	 * @param passengerId
	 *            Passenger ID
	 * @param segment
	 *            Contains basic segment details of which this passenger segment will be based on.
	 */
	public DTOPaxSegment(Long passengerId, DTOSegment segment) {
		this.passengerId = passengerId;
		try {
			BeanUtils.copyProperties(this, segment);
			this.setId(null);
			this.setSegmentId(segment.getId());
		} catch (IllegalAccessException e) {
			throw new RuntimeException("Error copying properties of : " + segment.getClass().getName(), e);
		} catch (InvocationTargetException e) {
			throw new RuntimeException("Error copying properties of : " + segment.getClass().getName(), e);
		}
	}


	@Override
	public String toString() {
		StringBuffer buf = new StringBuffer();
		buf.append("Pax ID: ").append(getPassengerId())
			.append(" ")
//			.append("Product: ").append(getProductApplied() == null ? "-" : getProductApplied().getCode())
			.append(" ")
			.append(super.toString());
		
		return buf.toString();
	}

	public Long getPassengerId() {
		return passengerId;
	}

	public void setPassengerId(Long passengerId) {
		this.passengerId = passengerId;
	}
	
	public Long getSegmentId() {
		return segmentId;
	}

	public void setSegmentId(Long segmentId) {
		this.segmentId = segmentId;
	}

	public DTOTicket getTicketIssued() {
		return ticketIssued;
	}

	public void setTicketIssued(DTOTicket ticketIssued) {
		this.ticketIssued = ticketIssued;
	}
	
//	public DTOProduct getProductApplied() {
//		return productApplied;
//	}
//
//	public void setProductApplied(DTOProduct product) {
//		this.productApplied = product;
//	}
	
	public double getMarketFare() {
		return marketFare;
	}

	public void setMarketFare(double marketFare) {
		this.marketFare = marketFare;
	}

	public double getNetFare() {
		return netFare;
	}

	public void setNetFare(double netFare) {
		this.netFare = netFare;
	}

	public double getAirportTax() {
		return airportTax;
	}

	public void setAirportTax(double airportTax) {
		this.airportTax = airportTax;
	}

	public double getFuelTax() {
		return fuelTax;
	}

	public void setFuelTax(double fuelTax) {
		this.fuelTax = fuelTax;
	}

	public double getOtherTaxes() {
		return otherTaxes;
	}

	public void setOtherTaxes(double otherTaxes) {
		this.otherTaxes = otherTaxes;
	}

	public double getInsurance() {
		return insurance;
	}

	public void setInsurance(double insurance) {
		this.insurance = insurance;
	}

	public double getAgentFeeRate() {
		return agentFeeRate;
	}

	public void setAgentFeeRate(double agentFeeRate) {
		this.agentFeeRate = agentFeeRate;
	}

	public double getSpFeeRate() {
		return spFeeRate;
	}

	public void setSpFeeRate(double spFeeRate) {
		this.spFeeRate = spFeeRate;
	}

	public double getAgentFee() {
		return agentFee;
	}

	public void setAgentFee(double agentFee) {
		this.agentFee = agentFee;
	}

	public double getSpFee() {
		return spFee;
	}

	public void setSpFee(double spFee) {
		this.spFee = spFee;
	}

	public String getFareBasis() {
		return fareBasis;
	}

	public void setFareBasis(String fareBasis) {
		this.fareBasis = fareBasis;
	}

	public Date getNotValidBefore() {
		return notValidBefore;
	}

	public void setNotValidBefore(Date notValidBefore) {
		this.notValidBefore = notValidBefore;
	}

	public Date getNotValidAfter() {
		return notValidAfter;
	}

	public void setNotValidAfter(Date notValidAfter) {
		this.notValidAfter = notValidAfter;
	}

	public String getAllow() {
		return allow;
	}

	public void setAllow(String allow) {
		this.allow = allow;
	}

	public SegmentStatus getStatus() {
		return status;
	}

	public void setStatus(SegmentStatus status) {
		this.status = status;
	}

	public TicketStatus getTicketStatus() {
		return ticketStatus;
	}

	public void setTicketStatus(TicketStatus ticketStatus) {
		this.ticketStatus = ticketStatus;
	}

	public List<DTOPaxSegmentService> getServiceList() {
		return serviceList;
	}

	public void setServiceList(List<DTOPaxSegmentService> serviceList) {
		this.serviceList = serviceList;
	}

	public int getSequence() {
		return sequence;
	}

	public void setSequence(int sequence) {
		this.sequence = sequence;
	}

	/**
	 * @return the hasFreeTicket
	 */
	public String getHasFreeTicket()
	{
		return hasFreeTicket;
	}

	/**
	 * @param hasFreeTicket the hasFreeTicket to set
	 */
	public void setHasFreeTicket(String hasFreeTicket)
	{
		this.hasFreeTicket = hasFreeTicket;
	}

	/**
	 * @return the usedFreeTicket
	 */
	public String getUsedFreeTicket()
	{
		return usedFreeTicket;
	}

	/**
	 * @param usedFreeTicket the usedFreeTicket to set
	 */
	public void setUsedFreeTicket(String usedFreeTicket)
	{
		this.usedFreeTicket = usedFreeTicket;
	}

	/**
	 * @return the usrdFlow
	 */
	public String getUsrdFlow()
	{
		return usrdFlow;
	}

	/**
	 * @param usrdFlow the usrdFlow to set
	 */
	public void setUsrdFlow(String usrdFlow)
	{
		this.usrdFlow = usrdFlow;
	}

	/**
	 * @return the payFreeTicket
	 */
	public String getPayFreeTicket()
	{
		return payFreeTicket;
	}

	/**
	 * @param payFreeTicket the payFreeTicket to set
	 */
	public void setPayFreeTicket(String payFreeTicket)
	{
		this.payFreeTicket = payFreeTicket;
	}


	/**
	 * @return the dayAndMoth
	 */
	public String getDayAndMoth()
	{
		return dayAndMoth;
	}

	
	/**
	 * @param dayAndMoth the dayAndMoth to set
	 */
	public void setDayAndMoth(String dayAndMoth)
	{
		this.dayAndMoth = dayAndMoth;
	}

	
	/**
	 * @return the hourAndmin
	 */
	public String getHourAndmin()
	{
		return hourAndmin;
	}

	
	/**
	 * @param hourAndmin the hourAndmin to set
	 */
	public void setHourAndmin(String hourAndmin)
	{
		this.hourAndmin = hourAndmin;
	}

	
	/**
	 * @return the insuranceList
	 */
	public List<DTOInsurance> getInsuranceList()
	{
		return insuranceList;
	}

	
	/**
	 * @param insuranceList the insuranceList to set
	 */
	public void setInsuranceList(List<DTOInsurance> insuranceList)
	{
		this.insuranceList = insuranceList;
	}


	
	/**
	 * @return the currency
	 */
	public String getCurrency()
	{
		return currency;
	}


	
	/**
	 * @param currency the currency to set
	 */
	public void setCurrency(String currency)
	{
		this.currency = currency;
	}


	public BigDecimal getCouponPrice() {
		if(couponPrice==null){
			couponPrice=new BigDecimal(0);
		}
		return couponPrice;
	}


	public void setCouponPrice(BigDecimal couponPrice) {
		if(couponPrice==null){
			couponPrice=new BigDecimal(0);
		}
		this.couponPrice = couponPrice;
	}


	public BigDecimal getOldNetFare() {
		if(oldNetFare==null){
			oldNetFare=new BigDecimal(0);
		}
		return oldNetFare;
	}


	public void setOldNetFare(BigDecimal oldNetFare) {
		if(oldNetFare==null){
			oldNetFare=new BigDecimal(0);
		}
		this.oldNetFare = oldNetFare;
	}


	public Long getOrderId() {
		return orderId;
	}


	public void setOrderId(Long orderId) {
		this.orderId = orderId;
	}


	public double getPointPrice() {
		return pointPrice;
	}


	public void setPointPrice(double pointPrice) {
		this.pointPrice = pointPrice;
	}

    public double getRealRebate() {
        return realRebate;
    }

    public void setRealRebate(double realRebate) {
        this.realRebate = realRebate;
    }


	public List<DTOEtAsrSeat> getSeatList() {
		return seatList;
	}


	public void setSeatList(List<DTOEtAsrSeat> seatList) {
		this.seatList = seatList;
	}


	public List<DTOSupportBusinessOrder> getSupportBusinessList() {
		return supportBusinessList;
	}


	public void setSupportBusinessList(
			List<DTOSupportBusinessOrder> supportBusinessList) {
		this.supportBusinessList = supportBusinessList;
	}


	public DTOPassenger getPass() {
		return pass;
	}


	public void setPass(DTOPassenger pass) {
		this.pass = pass;
	}


	public DTOOrderExtbuy getExtBuy() {
		return extBuy;
	}


	public void setExtBuy(DTOOrderExtbuy extBuy) {
		this.extBuy = extBuy;
	}


	public Long getRuleId() {
		return ruleId;
	}

	public void setRuleId(Long ruleId) {
		this.ruleId = ruleId;
	}


}
